package com.scf.preloanmanage.controller;

import com.scf.preloanmanage.entity.BorrowDemand;
import com.scf.preloanmanage.service.BorrowDemandService;
import com.scf.uitl.ResponseResult;
import org.springframework.boot.json.JacksonJsonParser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author author
 * @create 2021-11-17-10:31
 */
@RestController
@RequestMapping("/borrowDemand")
public class BorrowDemandController {
    @Resource
    BorrowDemandService borrowDemandService;

    @GetMapping("/get/{bmid}")
    public ResponseResult get(@PathVariable int bmid){
        BorrowDemand borrowDemand = borrowDemandService.getById(bmid);
        ResponseResult responseResult=new ResponseResult();
        responseResult.setData(borrowDemand);
        responseResult.setCode(200);
        responseResult.setMessage("查询成功");
        return responseResult;
    }

    @PostMapping("/update/{bmid}")
    public ResponseResult update(@PathVariable int bmid,@RequestBody BorrowDemand borrowDemand){
        System.out.println(borrowDemand);

        boolean b = borrowDemandService.updateById(bmid, borrowDemand.getOpinion());
        if(b){
            ResponseResult responseResult=new ResponseResult();
            responseResult.setData(null);
            responseResult.setCode(200);
            responseResult.setMessage("保存成功");
            return responseResult;
        }
        return null;
    }
}
